﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CoinTrigger : MonoBehaviour
{
    public void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.tag=="Player")
        {
            GameObjectPool.instance.CreateObject("Coin", Resources.Load<GameObject>("Prefabs/Item/Coin"), transform.position, Quaternion.identity,(i)=>i.transform.localScale=Vector3.one);
            collision.GetComponent<Character>().AddCoin(2);
            Destroy(gameObject);
        }
    }
}
